﻿Imports MySql.Data.MySqlClient
Public Class Flist_Builder

    Public con As New MySqlConnection
    Public DS As New DataSet
    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Label1.Text = ListBox1.Text
    End Sub

    Private Sub Flist_Builder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Try
            con.ConnectionString = "server=localhost; user id=root; password=toor; database=army_builder_database"
            con.Open()

            Dim Table As DataTable
            Dim query As String = "SELECT * FROM ejercitos "
            Dim Comando As New MySql.Data.MySqlClient.MySqlCommand(query, con)
            Dim Adap As New MySql.Data.MySqlClient.MySqlDataAdapter(Comando)
            DS.Clear()
            Adap.Fill(DS, "ejercitos")
            Dim CommBuild As New MySql.Data.MySqlClient.MySqlCommandBuilder(Adap)

            Table = DS.Tables("ejercitos")

            For i As Integer = 0 To Table.Rows.Count - 1
                ListBox1.Items.Add(Table.Rows(i).Item(1))
            Next

            ListBox1.SelectedIndex = 0
            Label1.Text = ListBox1.Text

            con.Close()

        Catch

        End Try

    End Sub






    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        If NumericUpDown1.Value = 0 Then
            MessageBox.Show("Indica el número de minis", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.Close()
        Fmain.Show()
    End Sub





    Private Sub ListBox1_SelectedIndexChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Label1.Text = ListBox1.Text
    End Sub
End Class